import { updateAutoCheckCancelOrder } from '@/api/network'
import { Ref, ref } from 'vue'

export default function (ids: Ref<Array<string>>) {
  // 批量自动审核取消工单策略加载
  const autoCheckCancelOrderLoading = ref(false)

  // 是否自动审核取消工单：false-手动审核，true-自动审核
  const autoCheckCancelOrder = ref(true)

  // 批量自动审核取消工单策略方法
  const autoCheckCancelOrderFn = async () => {
    autoCheckCancelOrderLoading.value = true
    const res = await updateAutoCheckCancelOrder(autoCheckCancelOrder.value, ids.value)
    autoCheckCancelOrderLoading.value = false
    return res.data as { code: number; data: object; message: string; success: boolean }
  }

  return {
    autoCheckCancelOrder,
    autoCheckCancelOrderLoading,
    autoCheckCancelOrderFn,
  }
}
